const app = getApp();

Page({
  data: {
    isAuthorize: true
  },
  onLoad: function() {
    const hasAuthorize = wx.getStorageSync('hasAuthorize');
    if (hasAuthorize) {
      this.setData({
        isAuthorize: false
      })
      wx.switchTab({
        url: "../home/home"
      })
    } else {
      this.setData({
        isAuthorize: true
      })
    }
  },
  getUserInfo: function (res) {
    if (res.detail.userInfo) {
      wx.setStorageSync('hasAuthorize', true);
      wx.setStorageSync('userInfo', res.detail);
      wx.switchTab({
        url: "../home/home"
      })
    } else {
      wx.showToast({
        title: '请先授权',
        icon: 'none',
        duration: 3000
      })
    }
  }
})